/**
 * 添加角色方法
 * @author    xiaogq
 * @param node
 */
function oper_add(node){
    var title = $(node).attr("title");
    var entityId = $(node).attr("tableCode");
    var tab = {id: "add"+entityId, text: "新建:"+title, url:"Role/roleAddInit.do?entityId="+entityId};
    parent.showTab(tab);
}

/**
 * 编辑角色方法
 * @author    xiaogq
 * @param node
 */
function fun_update(node){
    var id = $(node).attr("id");
    var title = $(node).attr("title");
    var entityId = $(node).attr("tableCode");
    var tab = {id: "edit"+entityId, text: "编辑:角色", url:"Role/roleEditInit.do?entityId="+entityId+"&id="+id};
    parent.showTab(tab);
}

/**
 * 查看角色详情方法
 * @author    xiaogq
 * @param node
 */
function fun_view(node){
    var id = $(node).attr("id");
    var title = $(node).attr("title");
    var rowName = $(node).attr("name");
    var entityId = $(node).attr("tableCode");
    var tab = {id: "view"+entityId, text: title, url:"Role/roleView.do?entityId="+entityId+"&id="+id+"&rowName="+rowName};
    parent.showTab(tab);
}

/**
 * 查看员工详情方法
 * @author    xiaogq
 * @param node
 */
function fun_view_employee(node){
    var id = $(node).attr("id");
    var title = $(node).attr("title");
    var rowName = $(node).attr("name");
    var entityId = $(node).attr("tableCode");
    var tab = {id: id, text: title, url:"Employee/employeeView.do?entityId="+entityId+"&id="+id+"&rowName="+rowName+"&isself=false"};
    parent.showTab(tab);
}

/**
 * 删除角色方法
 * @author    xiaogq
 * @param node
 */
function fun_delete(node){
    //获取当前记录id
    var id = $(node).attr("id");
    var entityId = $(node).attr("tableCode");
    var url = "Role/roleDelete.do";
    //获取删除按钮的位置(showList:列表上，showColumn：列前，showView：详情页上)
    var showHere = $(node).attr("showHere");
    if(confirm("确定要删除该条数据吗？")){
        $.ajax({
            type: 'POST',
            contentType: 'application/json',
            url: getRootPath()+"/"+ url +"?id="+id +"&entityId="+ entityId,
            dataType: 'json',
            success: function(data) {
                var flag = data.success;
                if(flag == "success"){
                    if(showHere == "showColumn"){
                        $("#bootstrapTable").bootstrapTable("refresh");
                    }else if(showHere == "showView"){
                        parent.closeTab(1);
                    }
                }else{
                    alert("管理员数据不能删除!");
                }
            },
            error: function(data) {
                alert("删除数据发生错误!");
            }
        });
    }
}

/**
 * 角色查看页系统权限方法
 * @author    xiaogq
 * @param     node
 */
function oper_sys_permission(node){
    //角色记录id
    var recodId = $(node).attr("id");
    var title = $(node).attr("title")+":"+$("#rowName").val()+":系统配置权限";
    var tab = {id: "sys"+recodId, text: title, url:"Role/queryRoleMenuPms.do?roleid="+recodId+"&kind=sys"};
    parent.showTab(tab);
}

/**
 * 角色查看页业务权限方法
 * @author    xiaogq
 * @param     node
 */
function oper_crm_permission(node){
    //角色记录id
    var recodId = $(node).attr("id");
    var title = $(node).attr("title")+":"+$("#rowName").val()+":业务配置权限"
    var tab = {id: "crm"+recodId, text: title, url:"Role/queryRoleMenuPms.do?roleid="+recodId+"&kind=bus"};
    parent.showTab(tab);
}

/**
 * 角色查看页操作权限方法
 * @author    xiaogq
 * @param     node
 */
function oper_opration_permission(node){
    //角色记录id
    var recodId = $(node).attr("id");
    var title = $(node).attr("title")+":"+$("#rowName").val()+":操作权限"
    var tab = {id: "opration"+recodId, text: title, url:"Role/queryRoleOperationPms.do?roleid="+recodId};
    parent.showTab(tab);
}

/**
 * 角色查看页数据权限方法
 * @author    xiaogq
 * @param     node
 */
function oper_data_permission(node){
    //角色记录id
    var recodId = $(node).attr("id");
    var title = $(node).attr("title")+":"+$("#rowName").val()+":数据权限"
    var tab = {id: "data"+recodId, text: title, url:"Role/queryRoleDataPms.do?roleid="+recodId};
    parent.showTab(tab);
}